#ifndef _MYPKG_H
#define _MYPKG_H

typedef enum{
	MSG_TYPE_LOGIN,
	MSG_TYPE_REG,
	MSG_TYPE_RET, 
	MSG_TYPE_SYSTEM, 
	MSG_TYPE_HEART,
	MSG_TYPE_LOGOUT,
	MSG_TYPE_MYSSH,
	MSG_TYPE_UPLOAD_START,
	MSG_TYPE_UPLOAD_CONTENT,
	MSG_TYPE_UPLOAD_END,
	MSG_TYPE_DOWNLOAD_START,
	MSG_TYPE_DOWNLOAD_CONTENT,
	MSG_TYPE_DOWNLOAD_END,
	MSG_TYPE_FRD_LIST,
	MSG_TYPE_FRD_ADD,
	MSG_TYPE_FRD_DELETE,
	MSG_TYPE_FRD_CHAT,
	MSG_TYPE_GRP_CHAT,
	MSG_TYPE_GRP_ADD,
	MSG_TYPE_GRP_MYGRP,
	MSG_TYPE_GRP_MEM,
	MSG_TYPE_NULL
}msg_type_t;//MSG_TYPE_NULL 标识枚举的结束，用户循环

typedef struct pat{
	char* str;
	int strLen;
	struct pat* next;
}param_t;

typedef struct{
	msg_type_t msg_type;
	int param_num;
	param_t* head;
	param_t* tail;
}pkg_t;

int pkg_pack_buf(char* sendBuf, msg_type_t type, int argc, ...);
int pkg_unpack(char* recvBuf, pkg_t* pkg);
int pkg_buf_check(char* buf, int len, char* errmsg);
int pkg_appendByteArr(char* sendBuf, char* byteArr, int arrLen);


//链表操作
pkg_t* pkg_create();
void pkg_setMsgType(msg_type_t msg_type);
void pkg_add(pkg_t* pkg, char* str, int strLen);
char* pkg_get(pkg_t* pkg, int i);
char* pkg_getbuf(pkg_t* pkg, int i, int* bufLen);
void pkg_free(pkg_t* pkg);














#endif
